package com.alks.function.controller;


import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.WebLogger;
import com.alks.entity.data.page.PageRecord;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.data.request.factorywork.*;
import com.alks.function.service.pcfactorywork.IPcDhLotHeadService;
import com.alks.function.service.pcfactorywork.IPcOutListPriceService;
import com.alks.function.service.pcfactorywork.IPcSupplementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 总经办-工厂作业模块 前端控制器
 * </p>
 *
 * @author ms
 * @since 2023-07-19
 */
@Api(value = "总经办", tags = {"总经办-工厂作业模块-补数审核作业", "总经办-工厂作业模块-外发单价审核"})
@ApiRestController("/pcFactorWork")
@RequiredArgsConstructor
public class PcFactorWorkController {
    private final IPcSupplementService sService;
    private final IPcOutListPriceService oService;
    private final IPcDhLotHeadService lService;

    @PutMapping("/listMtlHead")
    @ApiOperation(value = "补数审核-补料单-分页可条件查询", tags = "总经办-工厂作业模块-补数审核作业")
    @WebLogger
    public ResponseInfo listSupplementHaad(@RequestBody PcSupplementHeadRequest requet) {
        return sService.listSupplementHead(requet);
    }

    @GetMapping("/listMtlDetail/{slipNo}")
    @ApiOperation(value = "补数审核-材料明细-条件查询", tags = "总经办-工厂作业模块-补数审核作业")
    @WebLogger
    public ResponseInfo listSupplementMtl(@PathVariable String slipNo) {
        return sService.listSupplementMtl(slipNo);
    }

    @PutMapping("/listMtlLot")
    @ApiOperation(value = "补数审核-责任和指令-条件查询", tags = "总经办-工厂作业模块-补数审核作业")
    @WebLogger
    public ResponseInfo listSupplementLot(@RequestBody PcSupplementDetailRequest request) {
        return sService.listSupplementLot(request);
    }

    @PutMapping("/supFlagUpdate")
    @ApiOperation(value = "补数审核-退单审核-修改", tags = "总经办-工厂作业模块-补数审核作业")
    @WebLogger
    public ResponseInfo supFlagUpdate(@RequestBody SupFlagUpdateRequest request) {
        request.setReFlag(request.getReFlag() != null && request.getReFlag());
        return sService.supFlagUpdate(request);
    }

    @PutMapping("/supDetailDel")
    @ApiOperation(value = "补制明细删除-删除", tags = "总经办-工厂作业模块-补数审核作业")
    @WebLogger
    public ResponseInfo supDetailDel(@RequestBody SupDetailRequest request) {
        return sService.supDetailDel(request);
    }

    /*外发单价*/
    @PutMapping("/listOutHead")
    @ApiOperation(value = "外发单价-外发工艺指令-分页可条件查询", tags = "总经办-工厂作业模块-外发单价审核")
    @WebLogger
    public ResponseInfo<PageRecord> listPcOutPirce(@RequestBody PcOutListPriceRequest request) {
        return oService.listPcOutPirce(request);
    }

    @PutMapping("/listOutDetail")
    @ApiOperation(value = "外发单价-外发工艺单价-条件查询", tags = "总经办-工厂作业模块-外发单价审核")
    @WebLogger
    public ResponseInfo listPcOutPirceDetail(@RequestBody PcOutListPriceDetailRequest request) {
        return oService.listPcOutPirceDetail(request);
    }

    @PostMapping("/listOutVendor")
    @ApiOperation(value = "外发单价-全部-回表查询", tags = "总经办-工厂作业模块-外发单价审核")
    @WebLogger
    public ResponseInfo listPcOutVendor(@RequestParam(required = false) String vendor,
                                        @RequestParam(required = false) String process) {
        return oService.listPcOutVendor(vendor,process);
    }

    @PutMapping("/listOutDetailCheck")
    @ApiOperation(value = "外发单价-审核/取消审核-更新", tags = "总经办-工厂作业模块-外发单价审核")
    @WebLogger
    public ResponseInfo listOutDetailCheck(@RequestBody List<PcOutListPriceDetailRequest> request,
                                           @RequestParam @ApiParam("1 审核 0 取消审核") Integer flag) {
        return oService.listOutDetailCheck(request, flag);
    }

    /*外接单价审核*/
//
//    @PutMapping("/listDhHead")
//    @ApiOperation(value = "外接单价-指令资料-可条件分页查询", tags = "总经办-工厂作业模块-外接单价审核")
//    @WebLogger
//    public ResponseInfo listPcDhLot(@RequestBody PcDhLotRequest request) {
//        return lService.listPcDhLot(request);
//    }
//
//    @GetMapping("/listDhDetail/{lotNo}")
//    @ApiOperation(value = "外接单价-预算明细-条件查询", tags = "总经办-工厂作业模块-外接单价审核")
//    @WebLogger
//    public ResponseInfo listPcDhPrice(@PathVariable(value = "lotNo") String lotNo) {
//        return lService.listPcDhPrice(lotNo);
//    }
//
//    @PutMapping("/auditDhDetail")
//    @ApiOperation(value = "外接单价-指令资料-批量审核", tags = "总经办-工厂作业模块-外接单价审核")
//    @WebLogger
//    public ResponseInfo auditDhDetail(@RequestBody PcDhLotCFMRequest request) {
//        return lService.auditDhDetail(request);
//    }
//
//
//    @PostMapping("/listPcDhPriceExcel")
//    @ApiOperation(value = "外接单价-预算明细-导出明细（Excel）",tags = "总经办-工厂作业模块-外接单价审核")
//    @WebLogger
//    public ResponseInfo listPcDhPriceExcel(@RequestParam@ApiParam("指令") String lotNo, HttpServletResponse response){
//        Map<String, Object> data = lService.listPcDhPrice(lotNo).getData();
//        String templetName = "预算费用明细模版";
//        String excelName = "预算费用明细"+ DateUtils.dateTimeNow();
//        try {
//            ExcelUtils.creatByTemplate(response,templetName,excelName, (List<?>) data.get("dtos"),data);
//        } catch (IOException e) {
//            return ResponseInfo.error("导出失败");
//        }
//        return null;
//    }
//
//    @ApiOperation(value = "补料单资料", tags = "总经办-工厂查询模块-补单查询作业")
//    @PostMapping("/getSupplementaryOrder")
//    @WebLogger
//    public ResponseInfo getSupplementaryOrder(@RequestBody SupplementaryOrderRequest request) {
//        return sService.SupplementaryOrders(request);
//    }
//
//    @GetMapping("/getSupplementaryDetail")
//    @ApiOperation(value = "补制明细", tags = "总经办-工厂查询模块-补单查询作业")
//    @WebLogger
//    public ResponseInfo getSupplementaryDetail(@RequestParam String slipNo) {
//        return sService.getSupplementaryDetails(slipNo);
//    }
//
//    @ApiOperation(value = "条件返回", tags = "总经办-工厂查询模块-补单查询作业")
//    @GetMapping("/getDept2Type")
//    @WebLogger
//    public ResponseInfo getDept2Type() {
//        return sService.getDept2Type();
//    }
//
//    @ApiOperation(value = "插入外接单价", tags = "成控部-成本作业-外接单价输入")
//    @PutMapping("/InsertExternalInitPrice")
//    @WebLogger
//    public ResponseInfo InsertExternalInitPrice(@RequestBody PcLotPriceOtherUpdateRequest request) {
//        return lService.InsertExternalInitPrice(request);
//    }
//
//    @ApiOperation(value = "预算项目新增", tags = "成控部-成本作业-外接单价输入")
//    @PostMapping("/AddBudgetItem")
//    @WebLogger
//    public ResponseInfo AddBudgetItem(@RequestBody PcLotPriceOtherAddRequest request) {
//        return lService.AddBudgetItem(request);
//    }
//
//    @ApiOperation(value = "预算项目修改", tags = "成控部-成本作业-外接单价输入")
//    @PutMapping("/ModifyBudgetItems")
//    @WebLogger
//    public ResponseInfo ModifyBudgetItems(@RequestBody PcLotPriceOtherAddRequest request) {
//        return lService.ModifyBudgetItems(request);
//    }
//
//    @ApiOperation(value = "预算项目删除", tags = "成控部-成本作业-外接单价输入")
//    @PutMapping("/DeleteBudgetItems")
//    @WebLogger
//    public ResponseInfo DeleteBudgetItems(@RequestBody PcLotPriceOtherAddRequest request) {
//        return lService.DeleteBudgetItems(request);
//    }
}